import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import Problems from "../views/Problems.vue";
import User from "../views/User.vue";
import Main from '../views/Main.vue';
import PageOne from '../views/PageOne.vue';
import PageTwo from '../views/PageTwo.vue';
import Login from "../views/Login.vue";
import Register from "../views/Register.vue";

Vue.use(VueRouter)

const routes = [
    //主路由
    {
        path: '/',
        component: Main,
        redirect: '/home',
        children: [
            //子路由
            { path: 'home', component: Home },
            { path: 'problems', component: Problems },
            { path: 'user', component: User },
            { path: 'page1', component: PageOne },
            { path: 'page2', component: PageTwo },
        ]
    },
    {
        path: '/login',
        component: Login
    },
    {
        path: '/register', // 新增注册页面的路由
        component: Register
    }
]


const router = new VueRouter({
    routes //(缩写) 相当于 routes: routes
})

export default router

 